<template>
  <div>
    <line-chart-multid v-if="visitInfo.length !== 0" :fields="visitFields" :dataSource="visitInfo" :aliases="aliases" :height="400" ></line-chart-multid>
    <div class="empty" v-else>
      <span>未找到相关的数据</span>
    </div>
  </div>
</template>

<script>
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import {getVisitInfo } from '@/api/api'
  import { httpAction, getAction } from '@/api/manage'
  import moment from 'moment'
  export default{
    name:'TrendChart',
    components: {
      LineChartMultid
    },
    data () {
      return {
        deviceName:'',
        visitFields:['curr','volt'],
        visitInfo:[],
        url: {
          list: "/corp/lampData/list",
        },
        aliases:[
          {field:'curr',alias:'实时电流(A)'},
          {field:'volt',alias:'实时电压(V)'},
        ],
         wrapperCol: {
           xs: { span: 10 },
           sm: { span: 16 },
         },
         labelCol: {
           xs: { span: 1 },
           sm: { span: 2 },
         },
         date:null,
         date2:null,
      }
    },
    methods:{
      getWeatherData(e){
       getAction(this.url.list,e).then((res)=>{
         if(res.success){
           this.visitInfo = res.result.records.map(item=>({'curr':item.curr || '0','volt':item.volt || '0','type':item.createTime.slice(0,10)+','+item.createTime.substring(11)}))
         }else{
           this.$error({ content: res.message})
         }
       });
      }, 
    }
  }
</script>

<style>
  .empty{
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
</style>